﻿using EasyClassWEBAPI.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace EasyClassWEBAPI.EntityClass
{
    public class Post
    {
        [Key]
        [ScaffoldColumn(false)]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int PostID { get; set; }
        [Required]
        public string Title { get; set; }//标题
        [Required]
        public string Category { get; set; }//所属的类别
        [Required]
        public DateTime CreateTime { get; set; }//创建帖子的时间
        [Required]
        public string ContentName { get; set; }//帖子的文件名

        public int LikeCount { get; set; }//点赞次数
        public int LookCount { get; set; }//浏览次数
        
        public User User { get; set; }//外键导航创建Post的User
        
        public int StudyGroupID { get; set; }
        public StudyGroup StudyGroup { get; set; }

        //一条帖子可以有多条评论
        public List<Comment> Comments { get; set; }
        //一条帖子可以有多个附件
        public List<StudyResource> StudyResources { get; set; }
        [NotMapped]
        public byte[] Content { get; set; }//仅向前端传送数据的时候使用
    }
}
